'use strict';
var React = require('react');
var ReactRedux = require('react-redux');
var actions=require('../../actions/userOperation.js');

var HkfsLoginComponent=require('../../components/pc/HkfsLogin.jsx');
class HkfsLogin extends React.Component {
    constructor(props) {
        super(props);
        this.changeMsgCode=this.changeMsgCode.bind(this);
        this.getMsgImgByAjax=this.getMsgImgByAjax.bind(this);
        this.state={
            loadingImg:true
        }
    }

    //获取验证码
    getMsgImgByAjax(){
        this.setState({
            loadingImg:true
        });
        var self=this;
        this.props.dispatch(actions.getMsgCodeImg(function(){
            self.setState({
                loadingImg:false
            });
        }));
    }


    componentDidMount(){
        this.getMsgImgByAjax();
    }

    //改变验证码
    changeMsgCode(){
        this.getMsgImgByAjax();
    }

    render(){
        return <div className="HkfsRegisterContent">
            <img src="./images/pc/login_bg.jpg"/>
            <HkfsLoginComponent msgImgUrl={this.props.msgImgUrl} msgCodeClick={this.changeMsgCode} loading={this.state.loadingImg}></HkfsLoginComponent>
        </div>
    }
}

function mapStateToProps(state) {
    return Object.assign({}, state.userOperation);
}



module.exports = ReactRedux.connect(mapStateToProps)(HkfsLogin);